package com.zhou.common.mybatis.template.shiro;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.zhou.common.mybatis.template.shiro.zhou.config.BaseEntity;

import java.util.Collections;

public class CodeGeneratorUpdate {
    public static void main(String[] args) {

        String mysqlUrl = "jdbc:mysql://rm-9dp91q03l7vnh8788to.mysql.rds.aliyuncs.com:3306/xxl-job?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true";
        FastAutoGenerator.create(mysqlUrl, "root", "SZ_qaz@123")
                .globalConfig(builder -> {
                    builder.author("zhouxianfeng") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride()
                            .outputDir("D:\\workspace-personal2\\my-combine\\spring-security-test\\src\\test\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("org.example") // 设置父包名
                            .moduleName("core") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D:\\workspace-personal2\\my-combine\\spring-security-test\\src\\test\\resources")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("user")// 设置需要生成的表名
                            .entityBuilder().enableLombok().superClass(BaseEntity.class)
                    ; // 设置过滤表前缀
                })
                .templateConfig(builder -> {
                    //builder.controller("").service("").serviceImpl("").mapper("").mapperXml("").entity("");
                    builder.controller("");
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
